
package com.un10.controller;

import java.util.List;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

import com.un10.entity.Proclass;

import com.un10.service.ProclassService;
import com.un10.util.Result;

//��Ʒ����  ���Ʋ�
@Controller
public class ProclassController {

	@Autowired
	ProclassService proclassService;
//��ѯ
@RequestMapping("/houtai/getproclass")
@ResponseBody
//��bug 
public Object getproclass(@RequestParam("page")int page , @RequestParam ("limit")int limit,@RequestParam("className") String className) {
   int	page1=(page-1)*limit;
		 List<Proclass> prosclass=proclassService.findAllProclass(page1, limit,className);

		
		 if(className==null || className=="" ) {
			 className=null;
			     }
		int count=proclassService.getCount();
	   System.out.println(className);
	com.un10.util.Result res=new com.un10.util.Result(0, "",count, prosclass);
    return  res ;
}
	//���
  @RequestMapping("/houtai/proclassadd")
   @ResponseBody
   public Object proclassadd(@RequestParam Map<String, Object> map) {
	
	System.out.println(map.get("className"));
	int i = proclassService.findProclassAdd(map);
	Result res = new Result(0, "", i, true);
	return res;
}
  //�޸�
//�޸�
	@RequestMapping("/houtai/updateProclass")
	@ResponseBody
	public Object updateProclass(@RequestParam Map<String, Object> map) {
	
		int i = proclassService.findProclassUpdate(map);
		Result res = new Result(0, "", i, true);
		return res;
	}
  
  //ɾ��

  

	@RequestMapping("/houtai/deleteProclass")
	@ResponseBody
	public Object deleteProclass(@RequestParam("catID") Integer catID) {
		int i = proclassService.findProclassDelete(catID);
		Result res = new Result(0, "", i, true);
		return res;
	}
}
